﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>config_file_third_kind</title>
    <script src="~/lib/axios/dist/axios.js"></script>
    <script src="~/lib/vue/dist/vue.js"></script>
    <script src="~/lib/element-ui/lib/index.js"></script>
    <link href="~/lib/element-ui/lib/theme-chalk/index.css" rel="stylesheet" />
</head>
<body>
    <div id="app">
        <el-container>
            <el-header>
                <el-card class="box-card">
                    <el-col :span="2"> III级机构管理 </el-col><el-col :span="6" :offset="21"> 创建和维护III级机构 </el-col>
                </el-card>
            </el-header>
            <el-main>
                <el-card class="box-card">
                    <el-button type="primary"
                               @@click="dialogVisibleinsert = true"
                               style="float: right; margin-bottom: 20px;">添加</el-button>
                    <el-table :data="list1" style="width: 100%" border stripe>
                        <el-table-column prop="first_kind_name"
                                         label="I级机构名称"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="second_kind_name"
                                         label="II级机构名称"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="second_kind_id"
                                         label="II级机构编号"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="third_kind_name"
                                         label="III级机构名称"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="third_kind_sale_id"
                                         label="销售责任人编号"
                                         align="center">
                        </el-table-column>
                        <el-table-column prop="third_kind_is_retail"
                                         label="是否为零售店"
                                         align="center">
                        </el-table-column>
                        <el-table-column label="操作" align="center">
                            <template slot-scope="scope">
                                <el-button size="mini" type="primary" @@click="cz(scope.row)">编辑</el-button>
                                <el-button size="mini" type="danger" @@click="delt(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>

                    <el-row>
                        <el-col :span="1">
                            <el-pagination v-on:size-change="handleSizeChange"
                                           v-on:current-change="handleCurrentChange"
                                           :current-page="queryinfo.currentPage"
                                           :page-sizes="[1, 2, 3, 4]"
                                           :page-size="queryinfo.pageSize"
                                           layout="total, sizes, prev, pager, next, jumper"
                                           :total="total">
                            </el-pagination>
                        </el-col>
                    </el-row>
                </el-card>
            </el-main>
        </el-container>
        <el-dialog title="III级机构修改"
                   :visible.sync="dialogVisibleUpdate"
                   width="50%">
            <el-form ref="formUpdate"
                     :model="formUpdate"
                     :rules="formruleUpdate"
                     label-width="80px">
                <el-form-item label="机构选择" prop="value">
                    <div class="block">
                        <el-cascader v-model="formUpdate.value"
                                     :options="list3"
                                     ref="cascaderAddr1"
                                     style="width: 100%"
                                     @@change="adminSelect1"></el-cascader>
                    </div>
                </el-form-item>
                <el-form-item label="III级机构编号" prop="third_kind_id" label-width="105px">
                    <el-input v-model="formUpdate.third_kind_id"  style="width: 471px"></el-input>
                </el-form-item>
                <el-form-item label="III级机构名称" prop="third_kind_name" label-width="105px">
                    <el-input v-model="formUpdate.third_kind_name" style="width: 471px"></el-input>
                </el-form-item>
                <el-form-item label="销售责任人编号" prop="third_kind_sale_id" label-width="121px">
                    <el-input v-model="formUpdate.third_kind_sale_id" style="width: 455px"></el-input>
                </el-form-item>
                <el-form-item label="是否为零售店" prop="third_kind_is_retail" label-width="107px">
                    <el-select v-model="formUpdate.third_kind_is_retail"
                               placeholder="请选择是否为零售店"
                               style="width: 469px">
                        <el-option label="是" value="是"></el-option>
                        <el-option label="否" value="否"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @@click="dialogVisibleUpdate = false">取 消</el-button>
                <el-button type="primary" @@click="upda('formUpdate')">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="III级机构添加"
                   :visible.sync="dialogVisibleinsert"
                   width="50%">
            <el-form ref="forminsert"
                     :model="forminsert"
                     :rules="formruleinsert"
                     label-width="80px">
                <el-form-item label="机构选择" prop="value">
                    <div class="block">
                        <el-cascader v-model="forminsert.value"
                                     :options="list3"
                                     ref="cascaderAddr"
                                     style="width: 100%"
                                     @@change="adminSelect"></el-cascader>
                    </div>
                </el-form-item>
                <el-form-item label="III级机构编号" prop="third_kind_id" label-width="105px">
                    <el-input v-model="forminsert.third_kind_id"  style="width: 471px"></el-input>
                </el-form-item>
                <el-form-item label="III级机构名称" prop="third_kind_name" label-width="105px">
                    <el-input v-model="forminsert.third_kind_name"  style="width: 471px"></el-input>
                </el-form-item>
                <el-form-item label="销售责任人编号" prop="third_kind_sale_id" label-width="121px">
                    <el-input v-model="forminsert.third_kind_sale_id"  style="width: 455px"></el-input>
                </el-form-item>
                <el-form-item label="是否为零售店" prop="third_kind_is_retail" label-width="107px">
                    <el-select v-model="forminsert.third_kind_is_retail"
                               placeholder="请选择是否为零售店"
                               style="width: 469px">
                        <el-option label="是" value="是"></el-option>
                        <el-option label="否" value="否"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @@click="dialogVisibleinsert = false">取 消</el-button>
                <el-button type="primary" @@click="insert('forminsert')">确 定</el-button>
            </span>
        </el-dialog>
    </div>
    <script type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                list3: [],
                dialogVisibleUpdate: false,
                dialogVisibleinsert: false,
                list1: [],
                queryinfo: {
                    currentPage: 1,
                    pageSize: 3
                },
                total: 1,
                formUpdate: {
                    value: [],
                    ftk_id: "",
                    first_kind_id: "",
                    first_kind_name: "",
                    second_kind_id: "",
                    second_kind_name: "",
                    third_kind_id: "",
                    third_kind_name: "",
                    third_kind_sale_id: "",
                    third_kind_is_retail: "",
                },
                formruleUpdate: {
                    value: [
                        { required: true, message: '请选择机构', trigger: 'change' }
                    ],
                    third_kind_id: [
                        { required: true, message: '请输入III级机构编号', trigger: 'blur' }
                    ],
                    third_kind_name: [
                        { required: true, message: '请输入III级机构名称', trigger: 'blur' }
                    ],
                    third_kind_sale_id: [
                        { required: true, message: '请输入销售责任人编号', trigger: 'blur' }
                    ],
                    third_kind_is_retail: [
                        { required: true, message: '请选择是否为零售店', trigger: 'change' }
                    ],
                },
                forminsert: {
                    value: [],
                    first_kind_id: "",
                    first_kind_name: "",
                    second_kind_id: "",
                    second_kind_name: "",
                    third_kind_id: "",
                    third_kind_name: "",
                    third_kind_sale_id: "",
                    third_kind_is_retail: "",
                },
                formruleinsert: {
                    value: [
                        { required: true, message: '请选择机构', trigger: 'change' }
                    ],
                    third_kind_id: [
                        { required: true, message: '请输入III级机构编号', trigger: 'blur' }
                    ],
                    third_kind_name: [
                        { required: true, message: '请输入III级机构名称', trigger: 'blur' }
                    ],
                    third_kind_sale_id: [
                        { required: true, message: '请输入销售责任人编号', trigger: 'blur' }
                    ],
                    third_kind_is_retail: [
                        { required: true, message: '请选择是否为零售店', trigger: 'change' }
                    ],
                }
            },
            methods: {
                adminSelect(value, thsAreaCode) {
                    var thsAreaCode = this.$refs.cascaderAddr.getCheckedNodes()[0].pathLabels;
                    var forminsert = value;
                    this.forminsert.first_kind_id = forminsert[0];
                    this.forminsert.second_kind_id = forminsert[1];
                    this.forminsert.first_kind_name = thsAreaCode[0];
                    this.forminsert.second_kind_name = thsAreaCode[1];
                },
                adminSelect1(value, thsAreaCode) {
                    var thsAreaCode = this.$refs.cascaderAddr1.getCheckedNodes()[0].pathLabels;
                    var forminsert = value;
                    this.formUpdate.first_kind_id = forminsert[0];
                    this.formUpdate.second_kind_id = forminsert[1];
                    this.formUpdate.first_kind_name = thsAreaCode[0];
                    this.formUpdate.second_kind_name = thsAreaCode[1];
                },
                delt(row) {
                    this.$confirm('此操作将删除信息, 是否删除?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios.get('/config_file_third_kind/delt2', {
                            params: {
                                ftk_id: row.ftk_id,
                            }
                        })
                            .then(res => {
                                console.info(res);
                                this.$message({
                                    message: "删除成功",
                                    type: "success",
                                });
                                this.fill();
                            })
                            .catch(err => {
                                console.info(err);
                            })
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });
                    });
                },
                upda(formName) {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将修改信息, 是否修改?', '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                axios.get('/config_file_third_kind/Updat2', {
                                    params: {
                                        ftk_id: this.formUpdate.ftk_id,
                                        first_kind_id: this.formUpdate.first_kind_id,
                                        first_kind_name: this.formUpdate.first_kind_name,
                                        second_kind_id: this.formUpdate.second_kind_id,
                                        second_kind_name: this.formUpdate.second_kind_name,
                                        third_kind_id: this.formUpdate.third_kind_id,
                                        third_kind_name: this.formUpdate.third_kind_name,
                                        third_kind_sale_id: this.formUpdate.third_kind_sale_id,
                                        third_kind_is_retail: this.formUpdate.third_kind_is_retail,
                                    }
                                })
                                    .then(res => {
                                        console.info(res);
                                        this.$message({
                                            message: "修改成功",
                                            type: "success",
                                        });
                                        this.fill();
                                        this.dialogVisibleUpdate = false;
                                    })
                                    .catch(err => {
                                        console.info(err);
                                    })
                            }).catch(() => {
                                this.$message({
                                    type: 'info',
                                    message: '已取消修改'
                                });
                            });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                insert(formName) {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            this.$confirm('此操作将添加信息, 是否添加?', '提示', {
                                confirmButtonText: '确定',
                                cancelButtonText: '取消',
                                type: 'warning'
                            }).then(() => {
                                axios.get('/config_file_third_kind/Inser2', {
                                    params: {
                                        first_kind_id: this.forminsert.first_kind_id,
                                        first_kind_name: this.forminsert.first_kind_name,
                                        second_kind_id: this.forminsert.second_kind_id,
                                        second_kind_name: this.forminsert.second_kind_name,
                                        third_kind_id: this.forminsert.third_kind_id,
                                        third_kind_name: this.forminsert.third_kind_name,
                                        third_kind_sale_id: this.forminsert.third_kind_sale_id,
                                        third_kind_is_retail: this.forminsert.third_kind_is_retail,
                                    }
                                })
                                    .then(res => {
                                        console.info(res);
                                        this.$message({
                                            message: "添加成功",
                                            type: "success",
                                        });
                                        this.fill();
                                        this.dialogVisibleinsert = false;
                                    })
                                    .catch(err => {
                                        console.info(err);
                                    })
                            }).catch(() => {
                                this.$message({
                                    type: 'info',
                                    message: '已取消添加'
                                });
                            });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                cz(row) {
                    this.formUpdate.first_kind_id = row.first_kind_id;
                    this.formUpdate.second_kind_id = row.second_kind_id;
                    this.formUpdate.first_kind_name = row.first_kind_name;
                    this.formUpdate.second_kind_name = row.second_kind_name;
                    var rues = [];
                    rues.push(row.first_kind_id);
                    rues.push(row.second_kind_id);
                    this.formUpdate.value = rues;
                    this.formUpdate.third_kind_id = row.third_kind_id;
                    this.formUpdate.third_kind_name = row.third_kind_name;
                    this.formUpdate.third_kind_sale_id = row.third_kind_sale_id;
                    this.formUpdate.third_kind_is_retail = row.third_kind_is_retail;
                    this.formUpdate.ftk_id = row.ftk_id;
                    this.dialogVisibleUpdate = true;
                },
                fill() {
                    axios.get('/config_file_third_kind/Index5', {
                        params: {
                            currentPage: this.queryinfo.currentPage,
                            pageSize: this.queryinfo.pageSize
                        }
                    })
                        .then(res => {
                            console.info(res);
                            this.list1 = res.data.Data;
                            this.total = res.data.Row;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    axios.get('/config_file_third_kind/Inde2', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list3 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                },
                handleSizeChange(val) {
                    this.queryinfo.pageSize = val;
                    this.fill();
                },
                handleCurrentChange(val) {
                    this.queryinfo.currentPage = val;
                    this.fill();
                }
            },
            created: function () {
                this.fill();
            }
        });
    </script>
    <style scoped>

        .el-col-2 {
            width: 8.33333%;
            font-size: 15px;
            font-weight: 900;
            line-height: 0px;
        }

        .el-col-6 {
            width: 37.5%;
            font-size: 1px;
            font-weight: 300;
            color: rgb(83, 83, 83);
            line-height: 0px;
        }
        .el-card__body {
            padding: 35px;
        }
        element.style {
            height: 100%;
            width: 1239px;
        }

        .el-button.is-circle {
            border-radius: 50%;
            padding: 12px;
            position: relative;
            top: -10px;
            right: -570px;
        }
    </style>
</body>
</html>
